home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-05-01 | 3.6 KB | 141 lines | [TEXT/MPS ] |
- % ---------------------------------------------------------------------------
- % Class MACMenuBar
- %
- % In this module you find the programmers interface to Menus.
- % It is built on top of the toolbox routines in toolboxmenus.
- % For a description of the routines see Inside Macintosh, chapter 9.
- %
- % 890317/Boris Magnusson
- % 890330/Göran Eriksson
- %
- % ---------------------------------------------------------------------------
- external class MacMenu="::SInterfaces:MacMenu";
- external class MacPoint="::SInterfaces:MacPoint";
- external class toolboxmenu="::SInterfaces:toolboxmenu";
-
- simset class MACMenuBar;
- virtual: procedure doMenu is
- procedure doMenu(menuid,item); integer menuid,item;;
- begin
- ref(toolboxMenu) Trap;
- integer MenuBarHandle;
- ! ----------------------;
-
- procedure doMenu(menuid,item); integer menuid,item;
- inspect findMenu(Menuid) do
- doMenu(Menuid,item);
-
- PROCEDURE InitMenus;
- Trap.ToolboxInitMenus;
-
- ref(macMenu) procedure FindMenu(Menuid); integer MenuId;
- inspect findNotice(Menuid) do
- FindMenu:-aMenu;
-
- % FUNCTION GetNewMBar(menuBarID: INTEGER): Handle;
- procedure GetNewMBar(menuBarID);
- short integer menuBarID;
- begin
- MenuBarHandle:=TRAP.ToolboxGetNewMBar(menuBarID);
- ! build all list here and in each menu !!! ;
- end;
-
- % PROCEDURE InsertMenu(menu: MenuHandle; beforeId: INTEGER);
- PROCEDURE InsertMenu(menu, beforeId);
- ref(MacMenu) menu;
- short integer beforeId;
- begin
- ref(menuNotice) N;
- TRAP.toolboxInsertMenu(menu.menuHandle, beforeId);
- n:-findNotice(beforeId);
- if N=/=none then
- new MenuNotice(menu).precede(N)
- else
- new MenuNotice(menu).into(MenuQ);
- end;
-
- % PROCEDURE DeleteMenu(menuId: INTEGER);
- PROCEDURE DeleteMenu(menuId);
- short integer menuId;
- begin
- findNotice(MenuId).out;
- TRAP.toolboxDeleteMenu(menuId);
- end;
-
- PROCEDURE DrawMenuBar;
- TRAP.toolboxDrawMenuBar;
-
- PROCEDURE ClearMenuBar;
- begin
- TRAP.toolboxClearMenuBar;
- MenuQ.clear;
- end;
-
- % FUNCTION MenuSelect(startPt: Point): LONGINT;
- integer procedure MenuSelect(startPt);
- ref(MacPoint) startPt;
- MenuSelect:=TRAP.toolboxMenuSelect(startPt.h,startPt.v);
-
- % FUNCTION MenuKey(ch: CHAR): LONGINT;
- integer procedure MenuKey(ch);
- character ch;
- MenuKey:=TRAP.toolboxMenuKey(ch);
-
- % FUNCTION GetMenuBar: Handle;
- % procedure GetMenuBar;
- % begin
- % theMenuList:=ToolboxGetMenuBar;
- % end;
-
- % PROCEDURE SetMenuBar(menuList: Handle);
- % PROCEDURE SetMenuBar(aMenuBar);
- % ref(MacMenubar) aMenuBar;
- % ToolboxSetMenuBar(aMenuBar.theMenuList);
-
- % PROCEDURE HiliteMenu(menuId);
- PROCEDURE HiliteMenu(menuId);
- short integer menuId;
- TRAP.toolboxHiliteMenu(menuId);
-
- % PROCEDURE SetMenuFlash(flashCount: INTEGER);
- PROCEDURE SetMenuFlash(flashCount);
- short integer flashCount;
- TRAP.toolboxSetMenuFlash(flashCount);
-
- % PROCEDURE FlashMenuBar(menuId: INTEGER);
- PROCEDURE FlashMenuBar(menuId);
- short integer menuId;
- TRAP.toolboxFlashMenuBar(menuId);
-
- % FUNCTION GetMHandle(menuId: INTEGER): MenuHandle;
- % ref(MacMenu) procedure GetMHandle(menuId);
- % short integer menuId;
- % begin
- % TRAP.toolboxGetMHandle(menuId);
- % GetMHandle:-FindElementWith(menuId);
- % end;
- ! --------- Local routines -------- ;
-
- link class MenuNotice(aMenu); ref(macmenu) aMenu;;
- ref(Head) MenuQ;
- ref(MenuNotice) procedure findNotice(id); integer id;
- begin
- ref(MenuNotice) p;
- p:-MenuQ.first;
- while p=/=none and then p.aMenu.Menuid<>Id do
- p:-P.suc;
- findNotice:-p;
- end;
-
- integer procedure ostype(thetext);text thetext;
- begin ostype:=rank(thetext.getchar)*16R1000000+
- rank(thetext.getchar)*16R10000+
- rank(thetext.getchar)*16R100+
- rank(thetext.getchar);
- end;
-
- ! --- Init -- ;
-
- TRAP:-new toolboxmenu;
- MenuQ:- new Head;
- end --- Mac Menu Bar ---;